package com.qf.service.Impl;

import com.qf.dao.UserDao;
import com.qf.service.ImgService;
import com.qf.service.UserService;
import com.qfedu.entity.Img;

import com.qfedu.entity.User;

import com.qfedu.util.JsonTools;
import com.qfedu.vo.ResultVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;


    @Resource
    private ImgService imgService;
    /**
     * 通过uid查询用户信息
     * @param uid
     * @return  ResultVo
     */
    public ResultVo getUserByUid(Integer uid){
        try{
            User user = this.userDao.queryById(uid);
            imgService.getgetRoomImgUrlByImgId(user.getImgId());
            user.setImg(JsonTools.string2Obj(JsonTools.obj2String(JsonTools.string2Obj(imgService.getgetRoomImgUrlByImgId(user.getImgId()),ResultVo.class).getData()),Img.class));
            return ResultVo.getSuccessResultVo("查询成功",user);
        }catch (Exception e){
            e.printStackTrace();
            return ResultVo.getExceptionResultVo("网络异常",null);
        }
    }

}
